<html>
	<head>
		<?php
			echo '<script>';
			echo 'function verifyUser(){';
			echo 'var provided = "'. $_GET["user"] . '";';
			echo 'var login = sessionStorage.getItem("user");';
			echo 'if (login != provided){';
			echo 'window.location = "/index.html"';
			echo '}}';
			echo '</script>';
		?>
		<meta content "text/html; charset=utf-8" http-equiv="Content-Type">
		<title>Share My ToDo</title>
		<link rel="stylesheet" type="text/css" href="css/home.css" />
		<script src = "js/geo.js"></script>
		<STYLE type = "text/css">
			.marked:checked {
				-moz-box-shadow: 0px 0px 8px #CC0033;
				-webkit-box-shadow: 0px 0px 8px #CC0033;
				box-shadow: 0px 0px 8px #CC0033;
				
			}
			.marked:checked + .delete {
				text-decoration: line-through;
				color: 	#DDDDDD;
			}
		</style>
	</head>
	<body>
	<section>
		<a class="hiddenanchor" id="showCreate"></a>
		<a class="hiddenanchor" id="hideCreate"></a>
		<div id="fade"></div>
		<header>
			<?php 
			echo "<h1>" . $_GET["user"] . "'s ToDo</h1>";
			?>
			<a id="logout" href="/index.html">Logout</a></br><br/>
		</header>
		<nav>
			<ul id="tabs">
				<?php
				echo '<li id="home"><a href="home.php?user='.$_GET["user"].'">Home</a></li>';
				echo '<li><a href = "#showCreate">Create</a></li>';
				echo '<li><a href="view.php?user='.$_GET["user"].'">View&nbsp;All</a></li>';
				echo '<li class="active">Delete</li>';
				echo '<li id="profile"><a href="profile.php?user='.$_GET["user"].'">Profile</a></li>';
				echo '<li><a href="shared.php?user='.$_GET["user"].'">Shared</a></li>';
				?>
			</ul>
		</nav>
		<article id="main">
			<section id ="title">
				<h2> Delete Tasks</h2>
			</section>
			<section id="list">
			<form action="remove.php" method="post">
				<?php
					$link = mysql_connect('localhost','cs4350','!@'); 
					if (!$link) { 
						die('Could not connect to MySQL: ' . mysql_error()); 
					}
					if (!mysql_select_db('todo', $link)) {
						die('Aw snap, no database named todo...');
					}
					
					$sql = 'SELECT * FROM list WHERE user="'.$_GET["user"].'"';
					$result = mysql_query($sql, $link);
					
					if (!$result) {
						die($sql);
					}
					while ($row = mysql_fetch_array($result)){
						echo '<input type="checkbox" class="marked" id ="' . $row[taskID] . '" name="deleteMe[]" value=' . $row['taskID'] . ' />';
						echo '<label for="' . $row[taskID] . '"class="delete"> &nbsp&nbsp' . $row['taskName'] . '&nbsp&nbsp' . $row['createDate'] . '</label>';
						echo '<br/>';
					}
					echo '<input type="hidden" value="' . $_GET["user"] . '" name="username" />';
				?>
				<input type="submit" value="Delete" name="delete" class="button" />
			</form>
			</section>
		</article>
		<div id="create">
			<form action = "create.php" method = "post" class = "straight">
				<label for = "taskName">Task Name:</label>
					<input class="textbox" type="text" name="taskName" required="required"/><br/><br/>
				<label for = "taskDesc">Task Descrpition:</label><br/>
					<textarea class="textbox" name="taskDesc"; rows="5" cols="30" maxlength="250" /></textarea></br>
				<div id="local" class="small"></div>
				<input type="submit" value="Create" name="create" class="button" />
				<a href = "#hideCreate" class = "closeDialog"><input type="button" value="Cancel" name="cancel" class="button" /></a>
				<?php
					echo '<input type="hidden" value=' . $_GET["user"] . ' name="username" />';
				?>
			</form>
		</div>
	</section>
	</body>
</html>